package calculation;

import com.sun.scenario.effect.impl.sw.java.JSWBlend_SRC_OUTPeer;
import sun.applet.Main;

import java.util.Scanner;

public class Test {
    public static void main(String[] args){
        Main main = new Main();

        
        System.out.println("请选择计算方式");
        Scanner scanner = new Scanner(System.in);
        if (scanner.hasNextLine()) {
            String method = scanner.nextLine();
            if (method.equals("加法")) {
                System.out.println("请输入第一个数");
                double a =scanner.nextDouble();
                System.out.println("请输入第二个数");
                double b = scanner.nextDouble();
                double sum = a + b;
                System.out.println("两个数的和为"+sum);
            }else if (method.equals("减法")) {
                System.out.println("请输入被减数");
                double a =scanner.nextDouble();
                System.out.println("请输入减数");
                double b = scanner.nextDouble();
                double difference = a - b;
                System.out.println("两个数的差为"+difference);
            }else if (method.equals("乘法")) {
                System.out.println("请输入第一个数");
                double a = scanner.nextDouble();
                System.out.println("请输入第二个数");
                double b = scanner.nextDouble();
                double multiply = a * b;
                System.out.println("两个数的积为" + multiply);
            }else if (method.equals("除法")) {
                System.out.println("请输入被除数");
                double a = scanner.nextDouble();
                System.out.println("请输入除数");
                System.out.println("注意：除数不能为0！");
                double b = scanner.nextDouble();
                double divide = a / b;
                System.out.println("两个数的商为" + divide);
            }else if (method.equals("平方")) {
                System.out.println("请输入数字");
                double a = scanner.nextDouble();
                double square = Math.pow(a,2) ;
                System.out.println("平方为" + square);
            }else {
                System.out.println("输入错误");

        }
        }
        scanner.close();



    }
}